﻿using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace EntityframeworkHelper.Data.EntityExtend
{
    public abstract class EntityBase<TKey>
    {
        protected EntityBase()
        {
            this.CreatedBy = "System";
            this.CreatedTime = DateTime.UtcNow;
            this.UpdatedTime = DateTime.UtcNow;
        }

        /// <summary>
        ///     创建人
        /// </summary>
        public string CreatedBy { get; set; }

        /// <summary>
        ///     创建时间
        /// </summary>
        [Column(TypeName = "DateTime2")]
        public DateTime CreatedTime { get; set; }

        /// <summary>
        ///     主键标识
        /// </summary>
        [Key]
        public TKey Id { get; set; }

        ///// <summary>
        /////     用于并发处理
        ///// </summary>
        //[ConcurrencyCheck]
        //[Timestamp]
        //public byte[] Timestamp { get; set; }

        /// <summary>
        ///     更新人
        /// </summary>
        public string UpdatedBy { get; set; }

        /// <summary>
        ///     更新时间
        /// </summary>
        [Column(TypeName = "DateTime2")]
        public DateTime? UpdatedTime { get; set; }
    }
}